package com.neu.util;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.neu.po.ResponseResult;

//@ControllerAdvice
public class GlobalExcptionHandler {
	//@RestController=@Contriller+@ResponseBody
	//能够基于底层的配置，把返回值转换位json对象写入到http数据区
		@ResponseBody
		@ExceptionHandler(Exception.class)
		public ResponseResult exceptionHandler(Exception ex ) {
			 
			ResponseResult result= new ResponseResult();
			result.setResult("error");
			result.setData(ex.getMessage());
			return result;
		}
}
